package club.banyuan.phoy.cake;

/**
 * @author edz
 * @version 1.0
 * @date 2020/11/24 上午9:29
 */
public class CakeTool {
    private  static Cake[]cakes=new Cake[10];

    public CakeTool() {


    }
    public static void add(Cake cake){
        for (int i = 0; i <cakes.length ; i++) {
                if(cakes[i]==null&&i%2==0&&cake instanceof ReadyMadeCake){
                    cakes[i]=cake;
                    break;
                }
                if(cakes[i]==null&&i%2!=0&&cake instanceof OrderCake){
                    cakes[i]=cake;
                    break;
                }

        }
    }
    public static void print(){
        for (int i = 0; i <cakes.length ; i++) {
            if(cakes[i]!=null){
                System.out.println("下标为"+i+"，对应的蛋糕为:"+cakes[i]);
            }
        }
    }

}
class Test{
    public static void main(String[] args) {

    }
}
